class MakeFeaturesBackwardCompatible < ActiveRecord::Migration
  def self.up
    feature = Feature.new :name => "N/A"
    feature.save

    Deliverable.find(:all).each do |deliverable|
      if deliverable.feature == nil 
        deliverable.feature = feature 
        deliverable.save
      end
    end
  end

  def self.down
    feature = Feature.find_by_name "N/A"
    feature_id = feature.id
    deliverables = Deliverable.find_all_by_feature_id :feature_id => feature.id
    deliverables.each do |deliverable|

      #TODO This does not work correctly, may be fix it later
      deliverable.feature = nil
      deliverable.save
    end
    Feature.delete feature.id
  end
end
